package com.ly.model;

public class ResponseResult<T> {
    private int statusCode;
    private String message;
    private T data;

    // 默认构造方法
    public ResponseResult() {}

    // 构造方法
    public ResponseResult(int statusCode, String message, T data) {
        this.statusCode = statusCode;
        this.message = message;
        this.data = data;
    }

    public ResponseResult(int code, String msg) {
        this.statusCode = code;
        this.message = msg;
    }

    // 获取状态码
    public int getStatusCode() {
        return statusCode;
    }

    // 设置状态码
    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    // 获取消息
    public String getMessage() {
        return message;
    }

    // 设置消息
    public void setMessage(String message) {
        this.message = message;
    }

    // 获取数据
    public T getData() {
        return data;
    }

    // 设置数据
    public void setData(T data) {
        this.data = data;
    }

    // 创建成功结果的方法
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(200, "Success", data);
    }

    // 创建失败结果的方法
    public static <T> ResponseResult<T> error(int statusCode, String message) {
        return new ResponseResult<>(statusCode, message, null);
    }
}
